#!/bin/sh

export BASE_DIR=$(dirname $0)
export CLASSPATH=.:${BASE_DIR}/conf:${BASE_DIR}/lib/*:${CLASSPATH}

[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=$HOME/jdk/java
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/java
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=${BASE_DIR}/jre

export JAVA="$JAVA_HOME/bin/java"

JAVA_OPT="${JAVA_OPT} -Xms512m -Xmx512m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=256m"
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
JAVA_OPT="${JAVA_OPT} -Dlog_back_config=${BASE_DIR}/logback.xml -cp ${CLASSPATH}"

$JAVA ${JAVA_OPT} com.archive.cleaner.Main -c $@ ${BASE_DIR}/application.yml
